package v.e.fasterbuilder

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.runApplication
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.scheduling.annotation.EnableAsync
import java.util.concurrent.Executor

@SpringBootApplication
@EnableAsync
class KtApplication : SpringBootServletInitializer() {
    override fun configure(builder: SpringApplicationBuilder): SpringApplicationBuilder {
        builder.sources(KtApplication::class.java)
        return super.configure(builder)
    }


}

fun main(args: Array<String>) {
    val ac = runApplication<KtApplication>(*args)
    val executor=ac.getBean ("mySimpleAsync") as Executor
    val task=ac.getBean ("getMvnInstallTask") as MyTask
    task.setPath("C:\\code\\start.spring.io")
    executor.execute(task)

    val task2=ac.getBean ("getMvnInstallTask") as MyTask
    task2.setPath("C:\\code\\web_demo")
    executor.execute(task2)

    val task3=ac.getBean ("getMvnInstallTask") as MyTask
    task3.setPath("C:\\code\\web_demo2")
    executor.execute(task3)

    val task4=ac.getBean ("getMvnInstallTask") as MyTask
    task4.setPath("C:\\code\\web_demo3")
    executor.execute(task4)

}